package com.hq.fxh.No1_Infromation.Video.Adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hq.fxh.R;

/**
 * /**
 *
 * @author 薛
 * @ClassName
 * @Description :
 * @Created 2017/8/15
 * @Email xlwenhao1858@sina.com
 */


public class Adapter_List_VideoDetail extends BaseAdapter {

    CommentCallBack commentCallBack;
    boolean isShow;


    public Adapter_List_VideoDetail(boolean isShow, CommentCallBack commentCallBack) {
        this.commentCallBack = commentCallBack;
        this.isShow = isShow;
    }

    @Override
    public int getCount() {
        return 10;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(final int i, View convertView, ViewGroup parent) {
        View view = convertView;
        ViewHolder viewHolder = null;
        if (view == null || !(view.getTag() instanceof ViewHolder)) {
            view = LayoutInflater.from(parent.getContext()).inflate(R.layout.delatil_comment_item, null);
            viewHolder = new ViewHolder(view);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        if (isShow) {
            viewHolder.layoutDetailComment.setVisibility(View.VISIBLE);
        } else {
            viewHolder.layoutDetailComment.setVisibility(View.GONE);

        }
        viewHolder.layoutDetailComment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                commentCallBack.call(i);
            }
        });
        final ViewHolder finalViewHolder = viewHolder;
        viewHolder.layoutZan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                commentCallBack.callZhan(i, finalViewHolder.tvZan, finalViewHolder.imageZan);
            }
        });
        viewHolder.tvDetailHuiFu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                commentCallBack.callHuiFu(i);
            }
        });
        return view;
    }

    private void initView(View rootView) {

    }


    static class ViewHolder {
        protected ImageView imageZan;
        protected TextView tvZan;
        protected LinearLayout layoutZan;
        protected ImageView imageDetailIcon;
        protected TextView tvDetailName;
        protected TextView tvDetailHuiFu;
        protected TextView tvDetailCommentContent;
        protected TextView tvDetailCommenTime;
        protected TextView layoutCommentName1;
        protected TextView layoutCommentContent1;
        protected TextView layoutCommentName2;
        protected TextView layoutCommentContent2;
        protected TextView layoutCommentNum;
        protected LinearLayout layoutDetailComment;

        ViewHolder(View rootView) {
            initView(rootView);
        }

        private void initView(View rootView) {
            imageDetailIcon = (ImageView) rootView.findViewById(R.id.image_detail_Icon);
            tvDetailName = (TextView) rootView.findViewById(R.id.tv_detail_Name);
            tvDetailHuiFu = (TextView) rootView.findViewById(R.id.tv_detail_HuiFu);
            tvDetailCommentContent = (TextView) rootView.findViewById(R.id.tv_detail_CommentContent);
            tvDetailCommenTime = (TextView) rootView.findViewById(R.id.tv_detail_CommenTime);
            layoutCommentName1 = (TextView) rootView.findViewById(R.id.layout_Comment_name1);
            layoutCommentContent1 = (TextView) rootView.findViewById(R.id.layout_Comment_Content1);
            layoutCommentName2 = (TextView) rootView.findViewById(R.id.layout_Comment_name2);
            layoutCommentContent2 = (TextView) rootView.findViewById(R.id.layout_Comment_Content2);
            layoutCommentNum = (TextView) rootView.findViewById(R.id.layout_Comment_Num);
            layoutDetailComment = (LinearLayout) rootView.findViewById(R.id.layout_detail_Comment);
            imageZan = (ImageView) rootView.findViewById(R.id.image_Zan);
            tvZan = (TextView) rootView.findViewById(R.id.tv_Zan);
            layoutZan = (LinearLayout) rootView.findViewById(R.id.layout_Zan);
        }
    }

    public interface CommentCallBack {
        void call(int positon);

        void callZhan(int positon, TextView textView, ImageView imageView);

        void callHuiFu(int positon);
    }
}
